#include <types.h>

byte inb(word port) {
	byte ret;
	asm volatile ("INB	%1, %0"
			:"=a" (ret)
			:"d" (port));
	return ret;
}

word inw(word port) {
	word ret;
	asm volatile ("INW	%1, %0"
			:"=a" (ret)
			:"d" (port));
	return ret;
}

dword inl(word port) {
	dword ret;
	asm volatile ("INL	%1, %0"
			:"=a" (ret)
			:"d" (port));
	return ret;
}

void outb(word port, byte value) {
	asm volatile ("OUTB %b0, %w1"
			:
			:"a" (value), "d" (port));
}

void outw(word port, word value) {
	asm volatile ("OUTW	%w0, %w1"
			:
			:"a" (value), "d" (port));
}

void outl(word port, dword value) {
	asm volatile ("OUT %0, %w1"
			:
			:"a" (value), "d" (port));
}

